﻿using System.Windows;
using System.Windows.Browser;
using HelloWorld.Shared.Models;

namespace HelloWorld
{
    /// <summary>
    /// Add the ScriptableType attrbiute so the control can be accessed in javascript
    /// Also call HtmlPage.RegisterScriptableObject
    /// </summary>
    [ScriptableType]    
    public partial class Demo3
    {
        private readonly MainPageModel _model = new MainPageModel();

        public Demo3()
        {
            InitializeComponent();
            DataContext = _model;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _model.Doit();
        }

        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            // Tell the browser that it can interact with this page
            HtmlPage.RegisterScriptableObject("Sample", this);
        }
    }
}
